package com.heima.nio.socket.client;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author ZhengDp
 * @Date 2023/6/23 16:58
 */
@Slf4j
public class WriteClient {
    public static void main(String[] args) throws IOException {
        SocketChannel sc = SocketChannel.open();
        sc.connect(new InetSocketAddress("localhost",7777));
        // 客户端接收数据
        ByteBuffer buffer = ByteBuffer.allocate(1024*1024);
        while (true) {
            int read = sc.read(buffer);
            log.info("接收到的字节数 ： {}" ,read);
            buffer.clear();
        }
    }
}
